<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    #wai{
      width: 300px;
      height: 300px;
      background-color: blue;
      border: 10px salmon solid;
      margin: 60px;
      overflow: auto;
    }
    #nei{
      width: 500px;
      height: 500px;
      background-color: red;
      border: 10px thistle solid;
    }
    #txt{
      display: none;
    }
  </style>
</head>
<body>
  <div id="wai">
    <div id="nei"></div>
  </div>
  <p id="txt">txt</p>
  <script>
    var wai =document.querySelector("#wai");
    var nei = document.querySelector("#nei");
    var nei1 = document.getElementById("nei");
    var txt = document.getElementById("txt");
    // 盒子内部滚动出去的尺寸
    console.log(wai.scrollLeft);
    console.log(wai.scrollTop);
    wai.onscroll = function () {
      if (wai.scrollTop >= 100) {
        txt.style.display = "block"
      }else{
        txt.style.display = "none"
      }
      console.log(wai.scrollLeft);
      console.log(wai.scrollTop);
    }
    // 盒子内容的实际宽度和高度
    console.log(wai.scrollWidth);//(content-width)
    console.log(wai.scrollHeight);
    // 对比
    console.log("对比");
    console.log(wai.scrollWidth);//520px 500+10+10
    console.log(wai.clientWidth);//283px 300-滚动条宽度
    console.log(wai.offsetWidth);//320px 300+10+10+0

    </script>
</body>
</html>